Skip to content

refactor(usecases): rewrite pre-2018 ref-patterns to match ergonomics - #89

Merged
jhamill34 merged 2 commits into
claude/issue-1-clippy-lint-policyfrom
claude/issue-1-phase2-usecases
Aug 26, 2026
Merged

refactor(usecases): rewrite pre-2018 ref-patterns to match ergonomics#89
jhamill34 merged 2 commits into
claude/issue-1-clippy-lint-policyfrom
claude/issue-1-phase2-usecases

Conversation

@jhamill34

Copy link
Copy Markdown
Owner

Summary

Part of #85 (Phase 2 of #1). Stacked on #88 (Phase 1's lint policy PR) since that's what re-enabled clippy::ref_patterns/clippy::match_ref_pats/clippy::needless_borrowed_reference in the first place.

Converts every pre-2018 explicit-deref match/if-let site in usecases/* to plain match-ergonomics form:

  • if let &Some(ref x) = &y { ... }if let Some(x) = &y { ... }
  • match &value { &Variant(ref x) => ..., ... }match value { Variant(x) => ..., ... } (dropping &/ref from each arm; keeping the & on the scrutinee where the matched value isn't Copy/movable, so the binding mode — x: &T — is identical to before)
  • |&(_, ref item)| item|(_, item)| item

Purely syntactic — no behavior change, every site binds the exact same reference type as before.

Crates touched: service_loader (6 sites — the 4 closure-pattern sites in loaders/openapi/mod.rs plus one in lib.rs), execution_engine (14 sites — 2 more than originally scoped, found via a fresh clippy run: a matches! macro use and one more match arm), service_writer (11 sites).

service_writer now has zero ref_patterns/match_ref_pats/needless_borrowed_reference warnings. service_loader/execution_engine retain only pre-existing, out-of-scope warnings (too_many_lines, implicit_clone, doc_markdown) tracked in #86.

Test plan

  • cargo build -p service_loader -p execution_engine -p service_writer — clean.
  • cargo clippy -p service_loader -p execution_engine -p service_writer --all-features — zero ref_patterns/match_ref_pats/needless_borrowed_reference warnings remaining in any of the three crates.
  • cargo test -p service_loader -p execution_engine -p service_writer --all-features — 48 tests, 0 failures.
  • cargo build --workspace --all-features — clean.
  • cargo fmt --all -- --check — clean.

Generated by Claude Code

claude added 2 commits August 26, 2026 18:08
Part of #85 (Phase 2 of #1). Converts every &Some(ref x)/match &value {
&Variant(ref x) => ... } site in service_loader, execution_engine, and
service_writer to plain match-ergonomics form (Some(x), Variant(x)) --
purely syntactic, binds the identical reference type as before.

service_writer's clippy::ref_patterns/match_ref_pats/needless_borrowed_reference
warnings are now fully zero; service_loader/execution_engine only retain
pre-existing, out-of-scope warnings (too_many_lines, implicit_clone, etc.)
tracked separately in #86.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018VzKriyNnMHmqQ6UxPhsv2
… pass

traverse_map's if let &mut Value::Object(ref mut current) = current wasn't
flagged by clippy::ref_patterns/needless_borrowed_reference (those lints
don't cover &mut/ref mut shapes), but it's the same anti-pattern from #85's
inventory. Same match-ergonomics fix as the rest of that PR.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018VzKriyNnMHmqQ6UxPhsv2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants